# Copyright (c) 2015 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

"""
Default group widget used by the GroupedListView custom view via the
GroupedListViewItemDelegate item delegate.
"""


from qtpy import QtWidgets, QtCore
from .ui.group_widget import Ui_GroupWidget

class GroupWidget(QtWidgets.QWidget):
    toggle_expanded = QtCore.Signal(bool)
    def __init__(self, parent=None):
        super(GroupWidget, self).__init__(parent)
        self._ui = Ui_GroupWidget()
        self._ui.setupUi(self)
        self._ui.expand_box.toggled.connect(self._on_expand_box_toggled_changed)
        self.setStyleSheet('background-color:red;')
        self.is_show = False
    # def set_item(self, model_idx):
    def set_item(self, model_idx):
        label = model_idx.data()
        self._cb.setText(label)
        
    def show(self):
        self.is_show = True
        super(GroupWidget, self).show()

    def is_expanded(self):
        return self._ui.expand_box.isChecked()

    def set_expanded(self, expand=True):
        print(11111111111)
        self._ui.expand_box.setChecked(expand)

    def _on_expand_box_toggled_changed(self, state):
        print(22222222222)
        self.toggle_expanded.emit(state)

